perm filename ZEROP.MCL[TIM,LSP] blob
sn#647780 filedate 1982-03-05 generic text, type C, neo UTF8
COMMENT ā VALID 00004 PAGES
C REC PAGE DESCRIPTION
C00001 00001
C00002 00002 (defmacro repeat (n . forms)
C00006 00003 (timitz0) (timitz1)
C00008 00004 Analysis
C00010 ENDMK
Cā;
(defmacro repeat (n . forms)
`(progn . ,(do ((i n (1- i))
(a forms (setq a (append forms a))))
((= i 1) a))))
(defun timitz0 ()
((lambda (t1 x gt)
(do ((i 5000. (1- i)))
((= i 0))
(repeat 10 (zerop 0)))
(setq t1 (- (runtime) t1))
(setq gt (- (status gctime) gt))
(print (list 'runtime
(QUOTIENT (FLOAT (- t1 gt))
1000000.)))
(print (list 'gctime
(quotient (float gt) 1000000.))))
(runtime) ()(status gctime)))
(defun timitz1 ()
((lambda (t1 x gt)
(do ((i 5000. (1- i)))
((= i 0))
(repeat 10 (zerop 1)))
(setq t1 (- (runtime) t1))
(setq gt (- (status gctime) gt))
(print (list 'runtime
(QUOTIENT (FLOAT (- t1 gt))
1000000.)))
(print (list 'gctime
(quotient (float gt) 1000000.))))
(runtime) ()(status gctime)))
(defun timit=0 ()
((lambda (t1 x gt)
(do ((i 5000. (1- i)))
((= i 0))
(repeat 10 (= 0 0)))
(setq t1 (- (runtime) t1))
(setq gt (- (status gctime) gt))
(print (list 'runtime
(QUOTIENT (FLOAT (- t1 gt))
1000000.)))
(print (list 'gctime
(quotient (float gt) 1000000.))))
(runtime) ()(status gctime)))
(defun timit=1 ()
((lambda (t1 x gt)
(do ((i 5000. (1- i)))
((= i 0))
(repeat 10 (= 1 0)))
(setq t1 (- (runtime) t1))
(setq gt (- (status gctime) gt))
(print (list 'runtime
(QUOTIENT (FLOAT (- t1 gt))
1000000.)))
(print (list 'gctime
(quotient (float gt) 1000000.))))
(runtime) ()(status gctime)))
(defun timitequal0 ()
((lambda (t1 x gt)
(do ((i 5000. (1- i)))
((= i 0))
(repeat 10 (equal 0 0)))
(setq t1 (- (runtime) t1))
(setq gt (- (status gctime) gt))
(print (list 'runtime
(QUOTIENT (FLOAT (- t1 gt))
1000000.)))
(print (list 'gctime
(quotient (float gt) 1000000.))))
(runtime) ()(status gctime)))
(defun timitequal1 ()
((lambda (t1 x gt)
(do ((i 5000. (1- i)))
((= i 0))
(repeat 10 (equal 1 0)))
(setq t1 (- (runtime) t1))
(setq gt (- (status gctime) gt))
(print (list 'runtime
(QUOTIENT (FLOAT (- t1 gt))
1000000.)))
(print (list 'gctime
(quotient (float gt) 1000000.))))
(runtime) ()(status gctime)))
(timitz0) (timitz1)
(RUNTIME 3.938) (RUNTIME 4.054)
(GCTIME 1.457) (GCTIME 1.536)
(RUNTIME 3.961) (RUNTIME 4.02)
(GCTIME 1.503) (GCTIME 1.559)
(RUNTIME 3.978) (RUNTIME 4.014)
(GCTIME 1.519) (GCTIME 1.971)
(timit=0) (timit=1)
(RUNTIME 4.715) (RUNTIME 4.791)
(GCTIME 1.886) (GCTIME 1.593)
(RUNTIME 4.716) (RUNTIME 4.758)
(GCTIME 1.513) (GCTIME 1.582)
(RUNTIME 4.75) (RUNTIME 4.776)
(GCTIME 1.522) (GCTIME 1.981)
(timitequal0) (timitequal1)
(RUNTIME 4.382) (RUNTIME 4.647)
(GCTIME 1.966) (GCTIME 1.55)
(RUNTIME 4.383) (RUNTIME 4.657)
(GCTIME 1.582) (GCTIME 1.987)
(RUNTIME 4.288) (RUNTIME 4.736)
(GCTIME 1.524) (GCTIME 1.594)
Analysis
(EQUAL n m) does an EQ first (cain a,(b)), so (EQUAL n n) is
pretty fast. If n ā m, the next step is to see if n and m have
the same type. This is the usual BIBOP hackery. Then a dispatch
according to the type of n, followed by MOVE T,(A) CAMN A,(B).
(= n m) always looks at both of the types. Looking at each type
involves a JSP to a routine that dipatches on each type and
puts the value of the operand in TT. Thus, there are 2 JSP's
instead of 1 PUSHJ (equal case), 2 type dispatches (JRST @table(t)),
and 2 MOVEI tt,(a)'s and a CAME instead of one dispatch, one
MOVEI, and a CAIN.
Because of the EQ test at the beginning, and fortuitousness of the
arguments (small fixnums), (equal 1 0) (= 0 0) and (= 1 0) are pretty
close in time. (equal 0 0) is considerably faster.
(ZEROP n) looks at the type of n to see if it is numeric. If so
it does a JUMPE TT,TRUE on the value. Also, it has only 1 argument
to evaluate and type check.
QED